Websydian v6.1 online documentationOnline documentation - WebsydianExpress v3.5

Template Edit Points

Introduction

In prior versions of Websydian, you would loose any changes you had made to the template when re-running the template generator.

The introduction of edit points in the templates enables the developer / designer to introduce changes to the template that will not be overwritten when the template generator is run again.

The aim is to make it possible to generate a template, make manual changes to the generated template, change the definitions in the Plex model, and then rerun the template generator without loosing the changes you have entered in the template.

Edit points in the meta templates

To be able to insert the edit points in the generated templates, the meta templates contains special replacement markers that specify where the edit point should be inserted.

The edit point markers inserted in the generated templates has to be either HTML or JavaScript comments as they are only instructions to the template generator - not something that the browser should handle.

To create the correct comment marker for these two cases, the meta templates contains different special replacement markers for these two cases. The format of these markers are:

HTML comment:

/(%EDITPOINTHTM-NameOfEditPoint)

JavaScript comment:

/(%EDITPOINTJS-NameOfEditPoint)

Handling edit points in template generation

The first thing the template generation does, when it finds that it must create a new file (when it finds a new MAIN file to handle), is to see if the new file already exists in the folder you want to generate the new file to. If a corresponding file exists, it will be overwritten by the new template.

To retain the content of the edit points in the existing template, the content of all edit points will be extracted and written to a work (xml) file.

When the template generator function encounters one of these markers it inserts two comment lines:

HTML:

<!-- !wsyd.editpoint.begin - NameOfEditPoint -->
<!-- !wsyd.editpoint.end - NameOfEditPoint -->

JS:

// !wsyd.editpoint.begin - NameOfEditPoint
// !wsyd.editpoint.end - NameOfEditPoint

Between these markers the function will insert the previous content of the edit point.

Using the edit points

You must insert any changes that you want in the generated templates between the two comment lines of a suitable edit point if you want the change to be persistent.

Never remove or move the edit point markers.

You can create new edit point - but you should insert them in the meta template and then rerun the template generator. This will insert the edit point comment markers - and you are certain that they wont disappear next time you run the template generation. If you just insert the edit point directly in the generated template, the edit point will be removed when the template generation is run again.

Limitations

Only one instance of an edit point in a generated template

Due to the way, the content of the edit points are generated, each generated template can only contain one edit point with a given name.

If a generated template contains more than one instance of an edit point, all the edit points will be saved to the temporary file - but all the edit points in the changed template will have the content of the first edit point.

This means that you should never insert an edit point in the grid region of a meta template or in one of the meta templates that is used as a grid child - or if the meta template is included in a grid child.

In general, it is recommended that you only introduce edit points in the MAIN meta templates and their immediate child meta templates.

Removing edit point

If you change a meta template so that an edit point is removed, the content of the edit point will be lost when you rerun the template generation for any templates that has been generated using this meta template.

Referring objects on the page - which is then removed

In the edit points, you will very often refer to fields or other objects that has been defined for the page in the Plex model.

If the objects you are referring are then removed from the page in the Plex model, you will get an error when you use the generated template.

So in general, if you remove fields / events / child pages etc. from a page in the Plex model, you should check the edit points to see if the corresponding js-objects are being referenced.